package com.speedtickets.rest.services.impl;

import java.util.List;

import com.speedtickets.rest.dao.TicketDAO;
import com.speedtickets.rest.models.Ticket;
import com.speedtickets.rest.services.ITicketService;

public class TicketService implements ITicketService{
	
	private static TicketService _instance;
    
    private static TicketDAO _ticketDAO = TicketDAO.getInstance();
    
    public static TicketService getInstance(){
        if ( _instance == null ) {
        	_instance = new TicketService();
        }
        return _instance;
    }
    
    @Override
	public void createTicket( Ticket c ) throws Exception{
		_ticketDAO.save(c);
	}
    
    @Override
    public void updateTicket( Ticket c ) throws Exception{
    	_ticketDAO.update(c);
    }
    
    @Override
    public void deleteTicket( Ticket c ) throws Exception{
    	_ticketDAO.delete(c);
    }
    
    @Override
    public List<Ticket> findAllTickets() throws Exception{
    	return _ticketDAO.findAll();
    }
    
    @Override 
    public List<Ticket>findAllTickets(Integer limit, Integer offset){
    	return _ticketDAO.findAll(limit, offset);
    }
    
    @Override 
    public Ticket findTicketById( Long id ){
    	return _ticketDAO.findById(id);
    }


}
